var t = require("../../../@babel/runtime/helpers/defineProperty"), n = require("../../../@babel/runtime/helpers/objectWithoutProperties"), a = [ "url" ], e = getApp();

Page({
    data: {
        showInstructions: !1,
        explain: null,
        stock: {},
        num: null,
        share_num: null
    },
    onLoad: function(t) {
        this.getData();
    },
    getData: function() {
        var t = this, n = e.getNetAddresss("plugin.warehouse.frontend.controllers.gift.give.instructions");
        e._postNetWork({
            url: n,
            data: {
                stock_id: this.options.id
            },
            success: function(n) {
                var a = n.data;
                1 == a.result ? t.setData({
                    explain: a.data.explain,
                    stock: a.data.stock
                }) : (wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1e3
                }), setTimeout(function() {
                    wx.navigateBack({
                        delta: 1
                    });
                }, 1500));
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    creatGift: function() {
        if (this.data.num) {
            if (this.data.share_num) return Number(this.data.num) > Number(this.data.stock.nums) ? (wx.showToast({
                icon: "none",
                title: "已超出范围，当前库存为".concat(this.data.stock.nums),
                duration: 1e3
            }), void this.setData({
                num: this.data.stock.nums
            })) : void (Number(this.data.num) < Number(this.data.share_num) ? wx.showToast({
                icon: "none",
                title: "赠送数量需要大于分享人数",
                duration: 1e3
            }) : wx.navigateTo({
                url: "/packageI/warehouseFarm/warehouseFarmGiftDetail/warehouseFarmGiftDetail?mode=creat&gid=" + this.data.stock.id + "&nums=" + this.data.num + "&sNum=" + this.data.share_num
            }));
            wx.showToast({
                icon: "none",
                title: "请输入分享人数",
                duration: 1e3
            });
        } else wx.showToast({
            icon: "none",
            title: "请输入数量",
            duration: 1e3
        });
    },
    toUrl: function(t) {
        var n = t.currentTarget.dataset || {};
        this.wxRouterLink(n);
    },
    wxRouterLink: function(t) {
        var e = "", i = t.url, o = n(t, a);
        Object.keys(o).forEach(function(t) {
            "" !== o[t] && (e += t + "=" + o[t] + "&");
        }), "" !== i && wx.navigateTo({
            url: i + "?" + e.slice(0, -1)
        });
    },
    openPopup: function(n) {
        var a = n.currentTarget.dataset;
        if (a.tag) {
            var e = a.tag;
            this.setData(t({}, e, a.set));
        }
    },
    bindinput: function(t) {
        this.setData({
            num: t.detail.value
        });
    },
    bindinputSnum: function(t) {
        this.setData({
            share_num: t.detail.value
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});